package com.adcc.monitoragent.bean;

import java.io.Serializable;
/**
 * jvmName唯一确定一个虚拟机，也可以根据服务来确定
 * 服务所在的java虚拟机信息
 * @author charlie
 *
 */
public class JvmMetricsBean implements Serializable {
	private static final long serialVersionUID = 1L;
	private String cpuRatio;//cpu占用率
	private MemoryMetricsBean heapMemory;//堆内存
	private MemoryMetricsBean nonHeapMemory;//非堆内存
	private ClassMetricsBean classInfo;//类加载信息
	private ThreadMetricsBean threadsInfo;//线程信息
	private GCMetricsBean concurrentMarkSweep;//并发标记扫描
	private GCMetricsBean parNew;//旧生代的GC
	private String runtimeName;//运行时名称
	private String jvmName;//虚拟机名称
	private long startTime;//启动时间
	
	public String getCpuRatio() {
		return cpuRatio;
	}
	public void setCpuRatio(String cpuRatio) {
		this.cpuRatio = cpuRatio;
	}
	public MemoryMetricsBean getHeapMemory() {
		return heapMemory;
	}
	public void setHeapMemory(MemoryMetricsBean heapMemory) {
		this.heapMemory = heapMemory;
	}
	public MemoryMetricsBean getNonHeapMemory() {
		return nonHeapMemory;
	}
	public void setNonHeapMemory(MemoryMetricsBean nonHeapMemory) {
		this.nonHeapMemory = nonHeapMemory;
	}
	public ClassMetricsBean getClassInfo() {
		return classInfo;
	}
	public void setClassInfo(ClassMetricsBean classInfo) {
		this.classInfo = classInfo;
	}
	public ThreadMetricsBean getThreadsInfo() {
		return threadsInfo;
	}
	public void setThreadsInfo(ThreadMetricsBean threadsInfo) {
		this.threadsInfo = threadsInfo;
	}
	public GCMetricsBean getConcurrentMarkSweep() {
		return concurrentMarkSweep;
	}
	public void setConcurrentMarkSweep(GCMetricsBean concurrentMarkSweep) {
		this.concurrentMarkSweep = concurrentMarkSweep;
	}
	public GCMetricsBean getParNew() {
		return parNew;
	}
	public void setParNew(GCMetricsBean parNew) {
		this.parNew = parNew;
	}
	public String getRuntimeName() {
		return runtimeName;
	}
	public void setRuntimeName(String runtimeName) {
		this.runtimeName = runtimeName;
	}
	public String getJvmName() {
		return jvmName;
	}
	public void setJvmName(String jvmName) {
		this.jvmName = jvmName;
	}
	public long getStartTime() {
		return startTime;
	}
	public void setStartTime(long startTime) {
		this.startTime = startTime;
	}
	/**
	 * jvm内存信息
	 * @author charlie
	 *
	 */
	public static class MemoryMetricsBean implements Serializable {
		private static final long serialVersionUID = 1L;
		private long used;//使用的内存
		private long alloc;//分配的内存
		private long max;//最大内存
		public long getUsed() {
			return used;
		}
		public void setUsed(long used) {
			this.used = used;
		}
		public long getAlloc() {
			return alloc;
		}
		public void setAlloc(long alloc) {
			this.alloc = alloc;
		}
		public long getMax() {
			return max;
		}
		public void setMax(long max) {
			this.max = max;
		}
		@Override
		public String toString() {
			return "MemoryMetricsBean [used=" + used + ", alloc=" + alloc
					+ ", max=" + max + "]";
		}
		
	}
	
	/**
	 * 类装载信息
	 * @author charlie
	 *
	 */
	public static class ClassMetricsBean implements Serializable {
		private static final long serialVersionUID = 1L;
		private int classesLoaded;//装载的类
		private long classesUnloaded;//为装载的类
		private long classesTotalloaded;//类总数
		public int getClassesLoaded() {
			return classesLoaded;
		}
		public void setClassesLoaded(int classesLoaded) {
			this.classesLoaded = classesLoaded;
		}
		public long getClassesUnloaded() {
			return classesUnloaded;
		}
		public void setClassesUnloaded(long classesUnloaded) {
			this.classesUnloaded = classesUnloaded;
		}
		public long getClassesTotalloaded() {
			return classesTotalloaded;
		}
		public void setClassesTotalloaded(long classesTotalloaded) {
			this.classesTotalloaded = classesTotalloaded;
		}
		@Override
		public String toString() {
			return "ClassMetricsBean [classesLoaded=" + classesLoaded
					+ ", classesUnloaded=" + classesUnloaded
					+ ", classesTotalloaded=" + classesTotalloaded + "]";
		}
		
	}
	
	/**
	 * jvm线程信息
	 * @author charlie
	 *
	 */
	public static class ThreadMetricsBean implements Serializable {
		private static final long serialVersionUID = 1L;
		private int threadsCurrent;//当前活动线程
		private int threadsPeak;//峰值
		private int threadsDaemon;//守护线程
		private long threadsTotal;//创建线程总数
		public int getThreadsCurrent() {
			return threadsCurrent;
		}
		public void setThreadsCurrent(int threadsCurrent) {
			this.threadsCurrent = threadsCurrent;
		}
		public int getThreadsPeak() {
			return threadsPeak;
		}
		public void setThreadsPeak(int threadsPeak) {
			this.threadsPeak = threadsPeak;
		}
		public int getThreadsDaemon() {
			return threadsDaemon;
		}
		public void setThreadsDaemon(int threadsDaemon) {
			this.threadsDaemon = threadsDaemon;
		}
		public long getThreadsTotal() {
			return threadsTotal;
		}
		public void setThreadsTotal(long threadsTotal) {
			this.threadsTotal = threadsTotal;
		}
		@Override
		public String toString() {
			return "ThreadMetricsBean [threadsCurrent=" + threadsCurrent
					+ ", threadsPeak=" + threadsPeak + ", threadsDaemon="
					+ threadsDaemon + ", threadsTotal=" + threadsTotal + "]";
		}
		
	}
	/**
	 * 垃圾回收信息
	 * @author charlies
	 *
	 */
	public static class GCMetricsBean implements Serializable {
		private static final long serialVersionUID = 1L;
		private long time;//时间
		private long count;//次数
		public long getTime() {
			return time;
		}
		public void setTime(long time) {
			this.time = time;
		}
		public long getCount() {
			return count;
		}
		public void setCount(long count) {
			this.count = count;
		}
		@Override
		public String toString() {
			return "GCMetricsBean [time=" + time + ", count=" + count + "]";
		}
		
	}
	
	@Override
	public String toString() {
		return "JvmMetricsBean [cpuRatio=" + cpuRatio + ", heapMemory="
				+ heapMemory + ", nonHeapMemory=" + nonHeapMemory
				+ ", classInfo=" + classInfo + ", threadsInfo=" + threadsInfo
				+ ", concurrentMarkSweep=" + concurrentMarkSweep + ", parNew="
				+ parNew + ", runtimeName=" + runtimeName + ", jvmName="
				+ jvmName + ", startTime=" + startTime + "]";
	}
	
	public static JvmMetricsBean createJvmMetrics() {
		
		return null;
	}
}
